package main

import (
	"errors"
	"fmt"
)

type doctor struct {
	Name string
	age  uint8 // 0~255
}

func NewDoctor(name string) *doctor {
	return &doctor{Name: name}
}

func (d *doctor) SetAge(age uint8) {
	if age > 0 && age < 150 {
		d.age = age
	} else {
		err := errors.New("年龄不合法")
		panic(err)
	}
}

func main() {
	doc := NewDoctor("魏教授")
	doc.SetAge(100)
	fmt.Println(*doc)
}
